package com.ss.android.article.base.feature.detail.presenter;

import com.ss.android.common.load.AsyncLoader.LoaderProxy;
import com.ss.android.http.legacy.HttpHeader;
import com.ss.android.http.legacy.a.LegacyHeader;
import com.ss.android.newmedia.f.Response;
import com.ss.android.newmedia.util.AppUtil;

import java.util.ArrayList;
import java.util.List;

final class CommonLoader implements LoaderProxy {
    private final DetailLoader mDetailLoader;

    CommonLoader(DetailLoader detailLoader) {
        this.mDetailLoader = detailLoader;

    }

    public final Object doInBackground(Object key, Object param, Object extra) {
        List<HttpHeader> headerList = new ArrayList();
        headerList.add(new LegacyHeader("Accept-Encoding", "gzip"));
        headerList.add(new LegacyHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"));
        AppUtil.appendHeaders(headerList, this.mDetailLoader.mUserAgent, this.mDetailLoader.mHttpRequestHeaders);
        return AppUtil.doHttpRequest(((String) key), headerList);
    }

    public final void onLoaded(Object key, Object param, Object extra, Object result) {
        DetailLoader.Callback v0 = this.mDetailLoader.mDetailLoaderCallbackRef.get();
        if(v0 != null) {
            v0.onLoaded(((String) key), ((Long) param).longValue(), ((Response) result));
        }
    }
}

